from django.contrib.auth.models import Group, Permission
from rest_framework.decorators import action
from rest_framework.viewsets import ModelViewSet
from meiduo_admin.serializers.group import GroupSerializer
from meiduo_admin.utils import UserPageNum
from meiduo_admin.serializers.permission import PermissionSerializer
from rest_framework.response import Response

class GroupView(ModelViewSet):
    serializer_class = GroupSerializer
    queryset = Group.objects.all()
    pagination_class = UserPageNum

    # @action(methods=['get'],detail=False)
    def simple(self, request):
        """
        获取权限表数据
        :param request:
        :return:
        """
        pers = Permission.objects.all()
        ser = PermissionSerializer(pers, many=True)
        return Response(ser.data)